

public class lx {

	
	
	public static int[] numArray= {5,3,11,34,6,13,7,22,17,8,2};
	public static int sum=0;
	public static void main(String[] argc){
		
		
	
		
		
		
	int len=numArray.length;
	bubbleSort(len,11);
	for(int i=0;i<len;i++) {
		
		echo(numArray[i]+" ");
	}

		
		
		
		
		
		
		
		
	
	}
	
	
	
	
	public static void bubbleSort(int n,int gap) {
		
		int i=n,temp,j;
		boolean isOk=false;
		
		//  it seems last gap is 1 will better than bigger 1 so you could set cacul to last gap become 1
		for(i=gap; gap>=1;gap= gap-2) {
			
			
			isOk=true;
			echoln("gap is:"+gap);
			for(j=0;j<n-gap;j++) {
				
				if(numArray[j] < numArray[j+gap]) {
					
					 temp=numArray[j+gap];
					numArray[j+gap]=numArray[j];
					numArray[j]=temp;
					
					
				}
				
			}
			
			
			
		}
		
		
		
		
	}
	
	
	
	public static void echo(int  msg){
		
		
		System.out.print(msg);
	}
	public static void echo(String msg){
		
		
		System.out.print(msg);
	}
	public static void echoln(String msg) {
		
		
		echo(msg+"\n");
	}

	

}

